#ifndef VPSQL_H
#define VPSQL_H

#include "tracksql.h"

#define VPOKER_GAMEID_SIZE		16
typedef char VPokerGameID[VPOKER_GAMEID_SIZE];

class VPokerOpts;
class VPokerSavedGame;
class ShueSave;

//
// All money values are in cents (100 == $1, 25 == $.25, 1 == $.01)
//
// IMPORTANT:  Access to this class is NOT thread-safe.  That's handled at
//			   the next level up (with calls to lock()/unlock()).
//

class VPokerSQL : public TrackSQL
{
	public:
		VPokerSQL( const String&	DBDSN, const String& DBLogin,const String&	DBPassword);

		int32 getOptions(VPokerOpts*, uint8 machId, uint8 nHands, int32 creditValue);

		int32 getPlayerLimits(const PID&, int32 gameId, uint8 machId,
			int32* compFactor);

		int32 createGame(
			int32 casinoId, const PID&, VPokerGameID, uint8 machineID,
			bool8 forMoney, SESSIONID, int32 compFactor,
			int32 bet, int32 numDealt, uint8* dealt,
			uint8 nHands, int32 creditValue, VPokerSavedGame*,
			int32 *balance, int32* comp);

		int32 drawHand(uint8 nhand, VPokerGameID gid, 
			int32 numDrawn, uint8* drawn,
			int32 payout, int32 paytype );
		int32 drawHandRollBack( VPokerGameID gid );

		int32 drawDone(
			int32 casinoId, const PID&, VPokerGameID, uint8 machineID,
			bool8 forMoney, int32 creditValue,
			int32 payout, 
			bool8 dblUpActive,
			int32* balance, int32* comp);

		int32 doubleUpDeny(
			int32 casinoId, const PID&, VPokerGameID, uint8 machineID,
			bool8 forMoney, int32 creditValue,
			int32 payout,
			int32* balance, int32* comp);

		int32 doubleUpDeal(
			int32 casinoId, const PID&, VPokerGameID, bool8 forMoney,
			int32 round, uint8 dealt, ShueSave*,
			int32* balance, int32* comp);

		int32 doubleUpDraw(
			int32 casinoId, const PID&, VPokerGameID, uint8 machineID,
			bool8 forMoney, int32 creditValue,
			int32 round, uint8 drawn, uint8 winResult, int32 payout,
			int32* balance, int32* comp);

		int32 hasSavedGame(const PID&, uint8 machineID, uint8 nHands,int32 creditValue,
			bool8 forMoney, VPokerGameID, VPokerSavedGame*, bool8* exists);
		
		int32 getDrawnCards(VPokerGameID gid, uint8 cards[100][5], int32 *payouts, int32 *paytypes, int32 *savhands );

		int32 setSubGameData(VPokerGameID, uint8 index, uint8 data);
		bool8 getSubGameData(VPokerGameID, uint8 index, uint8* data);

		enum VPokerSQLError
		{
			BadSavedGame = TrackSQL::FIRST_GAME_ERROR,
			NotEnoughMoney
		};
};

#endif
